<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #f0f2f5;
            overflow: hidden; /* 禁止页面滚动 */
        }
        .form-container {
            max-width: 400px;
            width: 100%;
            padding: 20px;
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }
        h2 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 30px;
            padding-bottom: 15px;
            border-bottom: 2px solid #3498db;
        }
        form {
            display: flex;
            flex-direction: column;
        }
        div {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #333;
        }
        input {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
            font-size: 16px;
        }
        input:focus {
            outline: none;
            border-color: #3498db;
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
        }
        button {
            width: 100%;
            background-color: #2ecc71;
            color: white;
            border: none;
            padding: 14px;
            border-radius: 4px;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        button:hover {
            background-color: #27ae60;
        }
        .back-btn {
            background-color: #3498db;
            margin-top: 15px;
        }
        .back-btn:hover {
            background-color: #2980b9;
        }
        .error-message {
            color: #e74c3c;
            margin-top: 10px;
            font-size: 14px;
            text-align: center;
        }
    </style>
</head>
<body>
<div class="form-container">
    <h2>注册</h2>

    <form th:action="@{/register}" method="post">
        <div>
            <label>用户名：</label>
            <input type="text" name="username" required />
        </div>
        <div>
            <label>密码：</label>
            <input type="password" name="password" required />
        </div>
        <div>
            <label>手机号：</label>
            <input type="text" name="phone" required />
        </div>
        <div>
            <label>邮箱：</label>
            <input type="email" name="email" required />
        </div>
        <button type="submit">注册</button>
    </form>

    <p class="error-message" th:if="${error}">注册失败，请检查信息或重试。</p>

    <a href="/login">
        <button class="back-btn" type="button">返回登录</button>
    </a>
</div>
</body>
</html>